package com.geek.netty.util;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import java.io.IOException;

/**
 * @program geek-netty
 * @description: utils
 * @author: chanzhugang
 */
public class OkHttpUtils {

    public static OkHttpClient client = new OkHttpClient();

    public static String getString(String url) {
        Request request = new Request.Builder().url(url).build();
        String result = null;
        try {
            Response response = client.newCall(request).execute();
            result = response.body().string();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }

    public static void main(String[] args) {
        String url = "http://localhost:8801";
        String result = getString(url);
        System.out.println(result);
    }
}